package com.zc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import com.zc.service.RedisService;

@Service("redisService")
public class RedisServiceImpl implements RedisService{
	@Autowired
	private RedisTemplate<Object, Object> redisTemplate;
	@Override
	public boolean set(Object key, Object value) {
		try {
            redisTemplate.opsForValue().set(key, value);
            return true;
        } catch (Exception e) {
            System.out.println(e);
            return false;
        }
	}
	@Override
	public Object get(Object key) {
		Object result=redisTemplate.opsForValue().get(key);
		return result;
	}
	@Override
	public boolean hasKey(Object key) {
		return redisTemplate.hasKey(key);
	}
}
